package Demo;

import javax.swing.*;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Demo84 {
    public static void main(String[] args) {
        SwingDemo s = new SwingDemo("hello swing");
        Container c = s.getContentPane();
        c.setLayout(new FlowLayout());
        JButton button = new JButton("button");
        JLabel jLabel = new JLabel();
        button.addActionListener((e) -> {
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            String format = sdf.format(new Date());
            jLabel.setText(format);
            jLabel.setForeground(Color.red);
            jLabel.setToolTipText("now time");
        });
        c.add(button);
        c.add(jLabel);
        s.setVisible(true);

    }
}

class SwingDemo extends JFrame {
    public SwingDemo(String title) throws HeadlessException {
        super(title);
        setBounds(100, 100, 500, 500);
        setBackground(Color.white);
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }
}